package com.zl.task.controller;


import com.zl.task.dto.EnterpriseDTO;
import com.zl.task.service.IServiceChinaService;
import com.zl.task.util.resp.RespResult;
import com.zl.task.util.resp.RespUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yinlingeng
 * @since 2021-07-26
 */
@RestController
public class ServiceChinaController {

    @Autowired
    private IServiceChinaService chinaService;


    @ApiOperation("省份列表")
    @GetMapping("/listProvince")
    public RespResult<Object> listProvince() {
        try {
            return RespUtil.success(chinaService.listProvince());
        } catch (Exception e) {
            e.printStackTrace();
            return RespUtil.error(e.getMessage());
        }
    }

    @ApiOperation("市区列表")
    @GetMapping("/listCity")
    public RespResult<Object> listCity() {
        try {
            return RespUtil.success(chinaService.listCity());
        } catch (Exception e) {
            e.printStackTrace();
            return RespUtil.error(e.getMessage());
        }
    }

    @ApiOperation("根据省份展示市区列表")
    @GetMapping("/listCityByProvince")
    public RespResult<Object> listCityByProvince(String number) {
        try {
            return RespUtil.success(chinaService.listCityByProvince(number));
        } catch (Exception e) {
            e.printStackTrace();
            return RespUtil.error(e.getMessage());
        }
    }



}

